<thead><tr>
<th>Month</th>

<?php
//weekly subtable
include '../../functions.php';

$crop = $_GET['crops'];
$unit = substr($crop, strripos($crop, " - ") + 3); // gets just the name of the unit
$crop = substr($crop, 0, strripos($crop, " - ")); // finds the last position of occurence of " - " ==> takes only the crop name, not the units
$year = $_GET['year'];
$attributes = $_GET['attributes'];
$attributesArray = explode(';',$attributes);

foreach ($attributesArray as $attr) {
	print "<th>$attr</th>";
}
print "</tr></thead><tbody>";

$result = getRangeWeeklyCropData($year."-01-01",$year."-12-31",getCropId($crop),$attributesArray, getUnitId($unit), in_array('sales', $attributesArray) ? getCustomerId($_GET['customers']) : (in_array('amount_donated', $attributesArray) ? getCustomerId($_GET['donationCustomers']) : NULL)); 

foreach ($result as $week) {
	print "<tr>";
	foreach ($week as $a) {
		print "<td>$a</td>";
	}
	print "</tr>";
}

?>
</tbody>